package com.example.controller;


import com.example.pojo.LoginMsg;
import com.example.pojo.ScoreResult;
import com.example.pojo.Student;
import com.example.service.StudentHomePageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@CrossOrigin    //允许跨域访问
@RestController
public class StudentHomePageController {
    @Autowired
    private StudentHomePageService studentHomePageService;

    @PostMapping("/homePage")
    public ScoreResult homePage(@RequestBody LoginMsg loginMsg){
        log.info("{}访问首页", loginMsg.getUsername());
        List<Student> listStudent = studentHomePageService.homePage(loginMsg);
        log.info("{}返回",listStudent);
        return ScoreResult.success(listStudent);

    }

    @GetMapping("/select")
    public ScoreResult select(String username,String subjectName,String semester){
        log.info("{}访问查询", username);
        List<Student> listStudent = studentHomePageService.select(username, subjectName,semester);
        log.info("{}返回",listStudent);
        return ScoreResult.success(listStudent);
    }
}
